<template>
  <div class="app-container">
    <!-- 表单 -->
    <el-form :label-position="labelPosition" size="small" :model="form" :inline="true" label-width="50px">
      <el-form-item label="姓名" style="font-weight:bold;">
        <el-input v-model="form.name" placeholder="请输入姓名" style="width:150px;" clearable></el-input>
      </el-form-item>
      <!-- <el-form-item label="性别" style="font-weight:bold;">
        <el-select v-model="form.sex" placeholder="请选择性别" style="width:150px;" clearable>
          <el-option label="男" value="1"></el-option>
          <el-option label="女" value="0"></el-option>
        </el-select>
      </el-form-item> -->
      <el-form-item label="工号" style="font-weight:bold;">
        <el-input v-model="form.userName" placeholder="请输入工号" style="width:150px;" clearable></el-input>
      </el-form-item>
      <el-form-item label="电话" style="font-weight:bold;">
        <el-input v-model="form.tel" placeholder="请输入手机号" style="width:150px;" clearable></el-input>
      </el-form-item>
      <el-form-item label="状态" style="font-weight:bold;">
        <el-select v-model="form.state" placeholder="请选择状态" style="width:150px;" clearable>
          <el-option label="离职" value="0"></el-option>
          <el-option label="在职" value="1"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="校区" style="font-weight:bold;">
        <el-select v-model="form.campusId" placeholder="请选择校区" style="width:150px;" clearable>
          <el-option v-for="item in CampusName" :key="item.id" :label="item.name" :value="item.id"></el-option>
        </el-select>
      </el-form-item>
      <!-- <el-form-item label="部门" style="font-weight:bold;">
        <el-select v-model="form.deptId" placeholder="请选择部门" style="width:150px;" clearable>
          <el-option v-for="item in DepartmentName" :key="item.id" :label="item.departName" :value="item.id"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="院系" style="font-weight:bold;">
        <el-select v-model="form.collegeId" placeholder="请选择院系" style="width:150px;" clearable>
          <el-option v-for="item in CollegeName" :key="item.id" :label="item.name" :value="item.id"></el-option>
        </el-select>
      </el-form-item> -->
      <!-- <el-form-item label="角色" style="font-weight:bold;">
        <el-select v-model="form.clientRole" placeholder="请选择角色" style="width:150px;" clearable>
          <el-option v-for="item in Role" :key="item.id" :label="item.roleName" :value="item.id"></el-option>
        </el-select>
      </el-form-item> -->
    </el-form>
    <!-- 表单 -->



    <!-- 按钮 -->
    <div class="btnBox">
      <div class="btnBox_left">
        <el-button size="small" type="primary" @click="dialog_newly = true" icon="el-icon-folder-add">新增</el-button>
        <!-- <el-button type="danger" class="delete_button" icon="el-icon-delete">删除</el-button> -->
        <!-- <el-button size="small" type="success" icon="el-icon-download" @click="downLoadExcel" plain>下载校工信息模板</el-button>
        <el-button size="small" style="margin-left:10px;" type="success" plain icon="el-icon-download"
          @click="exportSchoolWorker">导出校工信息</el-button>
        <el-upload style="margin-left:10px;" action="#" :before-upload="beforeUpload" ref="newupload"
          :show-file-list="false" :http-request="uploadHttpRequest" :limit="3" :file-list="fileList">
          <el-button size="small" type="primary" plain icon="el-icon-upload2">导入校工信息</el-button>
        </el-upload> -->
      </div>
      <div>
        <el-button size="small" class="search_button" type="primary" icon="el-icon-search"
          @click="getDataList">查询</el-button>
        <el-button size="small" class="reset_button" icon="el-icon-refresh" @click="reset">重置</el-button>
      </div>
    </div>
    <!-- 按钮 -->

    <el-divider></el-divider>

    <!-- 表格 -->
    <el-table size="medium" ref="multipleTable" :data="tableData" border style="width: 100%"
      @selection-change="handleSelectionChange">
      <el-table-column prop="userName" label="工号" align="center"></el-table-column>
      <el-table-column prop="name" label="姓名" align="center"></el-table-column>
      <!-- <el-table-column prop="sex" label="性别" align="center">
        <template slot-scope="scope">
          <span v-if="scope.row.sex == 0">女</span>
          <span v-if="scope.row.sex == 1">男</span>
        </template>
      </el-table-column> -->
      <el-table-column prop="mobile" label="电话" align="center"></el-table-column>
      <el-table-column prop="campusName" label="校区" align="center"></el-table-column>
      <!-- <el-table-column prop="deptName" label="部门" align="center"></el-table-column> -->
      <!-- <el-table-column prop="collegeName" label="院系" align="center"></el-table-column> -->
     <!-- <el-table-column prop="roleId" label="角色" align="center">
        <template slot-scope="scope">
          <span v-for="item in Role" :key="item.id">
            <span v-if="(scope.row.roleId == item.id)">{{ item.roleName }}</span>
          </span>
        </template>
      </el-table-column> -->
      <!-- <el-table-column prop="power" label="登录权限" align="center">
        <template slot-scope="scope">
          <span v-if="(scope.row.power == 1)">小程序</span>
          <span v-if="(scope.row.power == 2)">PC端</span>
          <span v-if="(scope.row.power == 3)">小程序和PC端</span>
        </template>
      </el-table-column> -->
      <!-- <el-table-column prop="type" label="工种" align="center">
        <template slot-scope="scope">
          <span v-if="scope.row.type == 1">辅导员</span>
          <span v-if="scope.row.type == 2">院领导</span>
          <span v-if="scope.row.type == 3">楼长</span>
          <span v-if="scope.row.type == 4">后勤</span>
          <span v-if="scope.row.type == 5">财务</span>
        </template>
      </el-table-column> -->
      <el-table-column prop="state" label="状态" align="center">
        <template slot-scope="scope">
          <span v-if="scope.row.state == 0">离职</span>
          <span v-if="scope.row.state == 1">在职</span>
        </template>
      </el-table-column>
      <el-table-column prop="handle" label="操作" align="center">
        <template slot-scope="scope">
          <el-button size="mini" type="primary" plain @click="updateSchoolWorker(scope.row)">修改</el-button>
          <!-- <el-button size="mini" type="danger" plain>离职</el-button> -->
        </template>
      </el-table-column>
    </el-table>
    <!-- 表格 -->

    <el-pagination class="pagination" background layout="total, sizes, prev, pager, next, jumper" :total="total"
      :page-size="10" :page-sizes="[10, 20, 30, 40]" @current-change="handleCurrentChange"
      @size-change="handleSizeChange"></el-pagination>


    <!-- 添加校工弹窗 -->
    <el-dialog title="添加校工信息" :visible.sync="dialog_newly">
      <el-form :model="formNew" :label-position="labelPosition" label-width="90px" style="margin-left:10%;"
        >
        <el-form-item label="姓名 :" :rules="[{ required: true, message: '姓名不能为空' }]" prop="name">
          <el-input v-model="formNew.name" style="width:70%;" placeholder="请输入姓名" clearable></el-input>
        </el-form-item>
        <el-form-item label="电话 :" :rules="[{ required: true, message: '电话不能为空' }]" prop="phone">
          <el-input v-model="formNew.phone" style="width:70%;" placeholder="请输入电话" clearable></el-input>
        </el-form-item>
        <el-form-item label="工号 :" :rules="[{ required: true, message: '工号不能为空' }]" prop="userName">
          <el-input v-model="formNew.userName" style="width:70%;" placeholder="请输入工号" clearable></el-input>
        </el-form-item>
        <el-form-item label="密码 :" :rules="[{ required: true, message: '密码不能为空' }]" prop="password">
          <el-input v-model="formNew.password" style="width:70%;" placeholder="请输入密码" clearable></el-input>
        </el-form-item>
      <!-- <el-form-item label="身份证号 :" :rules="[{ required: true, message: '身份证号不能为空' }]" prop="idLast">
          <el-input v-model="formNew.idLast" style="width:510px;" placeholder="请输入身份证号后六位" clearable></el-input>
        </el-form-item>
        <el-form-item label="性别 :" :rules="[{ required: true, message: '性别不能为空' }]" prop="sex">
          <el-select v-model="formNew.sex" placeholder="请选择性别" style="width:200px;" clearable>
            <el-option label="男" value="1"></el-option>
            <el-option label="女" value="0"></el-option>
          </el-select>
        </el-form-item> -->
        <el-form-item label="校区 :" :rules="[{ required: true, message: '校区不能为空' }]" prop="campusId">
          <el-select v-model="formNew.campusId" placeholder="请选择校区" style="width:70%;" clearable>
            <el-option v-for="item in CampusName" :key="item.id" :label="item.name" :value="item.id"></el-option>
          </el-select>
        </el-form-item>
        <!-- <el-form-item label="院系 :">
          <el-select v-model="formNew.collegeId" placeholder="请选择院系" style="width:200px;" clearable>
            <el-option v-for="item in CollegeName" :key="item.id" :label="item.name" :value="item.id"></el-option>
          </el-select>
        </el-form-item> -->
        <!-- <el-form-item label="部门 :">
          <el-select v-model="formNew.deptId" placeholder="请选择部门" style="width:220px;" clearable>
            <el-option v-for="item in DepartmentName" :key="item.id" :label="item.departName"
              :value="item.id"></el-option>
          </el-select>
        </el-form-item> -->
        <!-- <el-form-item label="角色分配 :" :rules="[{ required: true, message: '角色分配不能为空' }]" prop="clientRole">
          <el-select v-model="formNew.clientRole" placeholder="请选择角色" style="width:200px;">
            <el-option label="辅导员" value="1"></el-option>
            <el-option label="院领导" value="2"></el-option>
            <el-option label="楼长" value="3"></el-option>
            <el-option label="后勤办公室" value="4"></el-option>
            <el-option label="财务处" value="5"></el-option>
            <el-option label="单校区负责人" value="6"></el-option>
            <el-option label="保卫处" value="7"></el-option>
          </el-select>
        </el-form-item> -->
       <!-- <el-form-item label="角色分配 :" :rules="[{ required: true, message: '角色分配不能为空' }]" prop="roleId">
          <el-select v-model="formNew.roleId" placeholder="请选择角色" style="width:200px;" clearable>
            <el-option v-for="item in Role" :key="item.id" :label="item.roleName" :value="item.id"></el-option>
          </el-select>
        </el-form-item> -->
        <el-form-item label="状态 :" :rules="[{ required: true, message: '状态不能为空' }]" prop="state">
          <el-select v-model="formNew.state" placeholder="请选择状态" style="width:70%;" clearable>
            <el-option label="离职" value="0"></el-option>
            <el-option label="在职" value="1"></el-option>
          </el-select>
        </el-form-item>
        <!-- <el-form-item label="登录权限 :" :rules="[{ required: true, message: '登录权限不能为空' }]" prop="power">
          <el-radio-group v-model="formNew.power" clearable>
            <el-radio label="小程序"></el-radio>
            <el-radio label="PC端"></el-radio>
            <el-radio label="小程序和PC端"></el-radio>
          </el-radio-group>
        </el-form-item> -->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialog_newly = false">取 消</el-button>
        <el-button type="primary" @click="addSchoolWorker" class="dialogbutton">确 定</el-button>
      </div>
    </el-dialog>
    <!-- 添加校工弹窗 -->

    <!-- 修改校工弹窗 -->
    <el-dialog title="修改校工" :visible.sync="dialog_change">
      <el-form :model="formChange" :label-position="labelPosition" label-width="80px" style="margin-left:10%;">
        <el-form-item label="姓名 :">
          <el-input v-model="formChange.name" style="width:70%;" placeholder="请输入姓名" clearable></el-input>
        </el-form-item>
        <el-form-item label="电话 :">
          <el-input v-model="formChange.phone" style="width:70%;" clearable></el-input>
        </el-form-item>
        <el-form-item label="工号 :">
          <el-input v-model="formChange.userName" style="width:70%;" placeholder="请输入工号" clearable></el-input>
        </el-form-item>
        <el-form-item label="密码 :">
          <el-input v-model="formChange.password" style="width:70%;" placeholder="请输入密码" clearable></el-input>
        </el-form-item>
        <!-- <el-form-item label="身份证号 :">
          <el-input v-model="formChange.idLast" style="width:510px;" placeholder="请输入身份证号后六位" clearable></el-input>
        </el-form-item> -->
       <!-- <el-form-item label="性别 :">
          <el-select v-model="formChange.sex" placeholder="请选择性别" style="width:200px;" clearable>
            <el-option label="男" value="1"></el-option>
            <el-option label="女" value="0"></el-option>
          </el-select>
        </el-form-item> -->
       <el-form-item label="校区 :">
          <el-select v-model="formChange.campusId" placeholder="请选择校区" style="width:70%;" clearable>
            <el-option v-for="item in CampusName" :key="item.id" :label="item.name" :value="item.id"></el-option>
          </el-select>
        </el-form-item>
        <!-- <el-form-item label="院系 :">
          <el-select clearable v-model="formChange.collegeId" placeholder="请选择院系" style="width:200px;">
            <el-option v-for="item in CollegeName" :key="item.id" :label="item.name" :value="item.id"></el-option>
          </el-select>
        </el-form-item> -->
       <!-- <el-form-item label="部门 :">
          <el-select clearable v-model="formChange.deptId" placeholder="请选择部门" style="width:220px;">
            <el-option v-for="item in DepartmentName" :key="item.id" :label="item.departName"
              :value="item.id"></el-option>
          </el-select>
        </el-form-item> -->
        <!-- <el-form-item label="角色分配 :">
          <el-select v-model="formChange.clientRole" placeholder="请选择角色" style="width:200px;">
            <el-option label="辅导员" value="1"></el-option>
            <el-option label="院领导" value="2"></el-option>
            <el-option label="楼长" value="3"></el-option>
            <el-option label="后勤办公室" value="4"></el-option>
            <el-option label="财务处" value="5"></el-option>
            <el-option label="单校区负责人" value="6"></el-option>
            <el-option label="保卫处" value="7"></el-option>
          </el-select>
        </el-form-item> -->
        <!-- <el-form-item label="角色分配 :">
          <el-select v-model="formChange.roleId" placeholder="请选择角色" style="width:200px;" clearable>
            <el-option v-for="item in Role" :key="item.id" :label="item.roleName" :value="item.id"></el-option>
          </el-select>
        </el-form-item> -->
        <el-form-item label="状态 :">
          <el-select v-model="formChange.state" placeholder="请选择状态" style="width:70%;" clearable>
            <el-option label="离职" value="0"></el-option>
            <el-option label="在职" value="1"></el-option>
          </el-select>
        </el-form-item>
       <!-- <el-form-item label="登录权限">
          <el-radio-group v-model="formChange.power" clearable>
            <el-radio label="小程序"></el-radio>
            <el-radio label="PC端"></el-radio>
            <el-radio label="小程序和PC端"></el-radio>
          </el-radio-group>
        </el-form-item> -->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialog_change = false">取 消</el-button>
        <el-button type="primary" @click="updateSchoolWorkerConfirm" class="dialogbutton">确 定</el-button>
      </div>
    </el-dialog>
    <!-- 修改维修工弹窗 -->

  </div>
</template>

<script>
import { getSchoolWorker, addSchoolWorker, updateSchoolWorker, uploadSchoolWorker, exportSchoolWorker, downLoadExcel } from '@/api/UserManage/SchoolWorker/index.js'
import { getCampusName } from '@/api/Building/index.js'
// import { getCollegeName } from '_api/DormManage/College/index.js'
// import { getDepartmentName } from '_api/DormManage/Department/index.js'
// import { getRoles } from '_api/RoleManage/index.js'
export default {
  data() {
    return {
      labelPosition: "right",
      dialog_newly: false,
      dialog_change: false,
      form: {
        campusId: "",
        collegeId: "",
        current: 0,
        deptId: "",
        field: "",
        name: "",
        order: "",
        pageSize: 10,
        sex: "",
        state: "",
        userName: "",
        tel: "",
        clientRole: ""
      },
      formNew: {
        campusId: "",
        // collegeId: "",
        // deptId: "",
        // clientRole: "",
        // power: "",
        // roleId: "",
        name: "",
        password: "",
        phone: "",
        // sex: "",
        state: "",
        userName: "",
        // idLast: ""
      },
      formChange: {
        id: "",
        campusId: "",
        // collegeId: "",
        // deptId: "",
        // clientRole: "",
        // power: "",
        // roleId: "",
        name: "",
        password: "",
        phone: "",
        // sex: "",
        state: "",
        userName: "",
        // idLast: ""
      },
      tableData: [],
      CampusName: [],
      CollegeName: [],
      DepartmentName: [],
      fileList: [],
      timeNow: "",
      total: 0,
      Role: ""
    }
  },
  methods: {
    handleSelectionChange() {

    },
    //重置
    reset() {
      this.form = {
        campusId: "",
        collegeId: "",
        current: 0,
        deptId: "",
        field: "",
        name: "",
        order: "",
        pageSize: 10,
        sex: "",
        state: "",
        userName: "",
        tel: "",
        clientRole: ""
      }
      this.getSchoolWorker()
    },
    // 导入校工信息
    uploadHttpRequest(data) {
      console.log(data)
      let fd = new FormData()
      fd.append('file', data.file)
      uploadSchoolWorker(fd).then(res => {
        if (res.data.success == true) {
          this.$message.success("导入成功！")
          this.reset()
        } else {
          this.$message({
            message: res.data.message,
            duration: 3000
          })
        }
      })

    },
    beforeUpload(file) {
      // console.log(file)
      // 校验
      let legalName = ["xlsx", "xls"];
      // 拿到后缀名
      let name = file.name.substring(
        file.name.lastIndexOf(".") + 1,
        file.name.length
      );
      if (legalName.includes(name)) {
        // console.log(legalName.includes(name));
      } else {
        this.$message.info("文件格式不对,仅限xls和xlsx");
        return false;
      }
    },
    //获取当前时间
    getCurrentTime() {
      var _this = this;
      let yy = new Date().getFullYear();
      let mm = new Date().getMonth() + 1;
      let dd = new Date().getDate();
      let hh = new Date().getHours();
      let mf = new Date().getMinutes() < 10 ? '0' + new Date().getMinutes() : new Date().getMinutes();
      let ss = new Date().getSeconds() < 10 ? '0' + new Date().getSeconds() : new Date().getSeconds();
      _this.gettime = yy + '/' + mm + '/' + dd + ' ' + hh + ':' + mf + ':' + ss;
      // console.log(_this.gettime)
      this.timeNow = _this.gettime
    },
    // 下载校工信息模板
    downLoadExcel() {
      downLoadExcel().then(res => {
        // console.log(res, "121212121212")
        const link = document.createElement('a')  //创建a标签
        const blob = new Blob([res.data], { type: 'application/vnd.ms-excel' }) //设置文件流
        link.style.display = 'none'// 设置连接
        link.href = URL.createObjectURL(blob)  //将文件流转化为blob地址
        this.getCurrentTime()
        link.download = '校工信息模板_' + this.timeNow
        document.body.appendChild(link) // 模拟点击事件
        link.click()  //设置点击事件
        this.$message.success('下载成功！')
      })
    },
    // 导出校工信息
    exportSchoolWorker() {
      exportSchoolWorker(this.form).then(res => {
        // console.log(res.data,"121212121")
        const link = document.createElement('a')  //创建a标签
        const blob = new Blob([res.data], { type: 'application/vnd.ms-excel' }) //设置文件流
        link.style.display = 'none'// 设置连接
        link.href = URL.createObjectURL(blob)  //将文件流转化为blob地址
        this.getCurrentTime()
        link.download = '校工信息报表_' + this.timeNow
        document.body.appendChild(link) // 模拟点击事件
        link.click()  //设置点击事件
        this.$message.success('导出成功！')
      })
    },
    //修改校工弹窗
    updateSchoolWorker(e) {
      console.log(e)
      this.dialog_change = true
      this.CampusName.forEach(item => {
        if (item.name == e.campusName) {
          this.formChange.campusId = item.id
        }
      })
      // this.CollegeName.forEach(item => {
      //   if (item.name == e.collegeName) {
      //     this.formChange.collegeId = item.id
      //   }
      // })
      // this.DepartmentName.forEach(item => {
      //   if (item.departName == e.deptName) {
      //     this.formChange.deptId = item.id
      //   }
      // })
      // if (e.power == 1) {
      //   this.formChange.power = "小程序"
      // }
      // if (e.power == 2) {
      //   this.formChange.power = "PC端"
      // }
      // if (e.power == 3) {
      //   this.formChange.power = "小程序和PC端"
      // }
      this.formChange.id = e.id
      // if (e.roleId != "" && e.roleId != null) {
      //   this.formChange.roleId = e.roleId
      // }
      this.formChange.name = e.name
      this.formChange.phone = e.mobile
      // this.formChange.sex = e.sex
      this.formChange.state = e.state
      this.formChange.userName = e.userName
      // this.formChange.idLast = e.idLast
      console.log(this.formChange)
    },
    //修改校工确认
    updateSchoolWorkerConfirm() {
      // if (this.formChange.power == "小程序") {
      //   this.formChange.power = 1
      // }
      // if (this.formChange.power == "PC端") {
      //   this.formChange.power = 2
      // }
      // if (this.formChange.power == "小程序和PC端") {
      //   this.formChange.power = 3
      // }
      // this.formChange.clientRole = this.formChange.roleId

      updateSchoolWorker(this.formChange).then(res => {
        // console.log(res)
        if (res.data.success == true) {
          this.dialog_change = false
          this.$message({
            message: '修改成功!',
            duration: 1000,
            type: 'success',
            onClose: () => {
              this.reset()
            }
          })
        } else {
          this.$message({
            message: res.data.message,
          })
        }
      })
    },
    // 添加校工
    addSchoolWorker() {
      // if (this.formNew.power == "小程序") {
      //   this.formNew.power = 1
      // }
      // if (this.formNew.power == "PC端") {
      //   this.formNew.power = 2
      // }
      // if (this.formNew.power == "小程序和PC端") {
      //   this.formNew.power = 3
      // }
      // this.formNew.clientRole = this.formNew.roleId
      // if (this.formNew.idLast == "") {
      //   this.$message("身份证号不能为空")
      //   return false
      // }
      addSchoolWorker(this.formNew).then(res => {
        console.log(res.status)
        if (res.data.success == true) {
          this.dialog_newly = false
          this.$message({
            message: '添加成功!',
            duration: 1000,
            type: 'success',
            onClose: () => {
              this.reset()
            }
          })
        } else {
          this.$message.info(res.data.message)
        }
      }).catch(error => {
        console.log(error.response)
        if (error.response.status != 200) {
          this.$message.info(error.response.data.message)
        }
      })
      // console.log(this.formNew)
    },
    // prev(e) {
    //   //上一页
    //   this.form.current = e-1
    //   this.getSchoolWorker()
    // },
    // next(e) {
    //   //下一页
    //   this.form.current = e-1
    //   this.getSchoolWorker()
    // },
    handleCurrentChange(e) {
      //当前页
      this.form.current = (e - 1) * 10
      this.getSchoolWorker()
    },
    handleSizeChange(e) {
      this.form.pageSize = e
      this.getSchoolWorker()
    },
    // 查询按钮
    getDataList() {
      this.form.current = 0
      this.getSchoolWorker()
    },
    //校工信息查询
    getSchoolWorker() {
      getSchoolWorker(this.form).then(res => {
        console.log(res)
        if (res.data.success == true) {
          this.tableData = res.data.data.list
          this.total = res.data.data.total
          // this.getRole()
          this.getCampusName()
          // this.getCollegeName()
          // this.getDepartmentName()
          // this.tableData.forEach(itemId => {
          //   this.Role.forEach(itemName => {
          //     if (itemId.roleId == itemName.id) {
          //       itemId.roleId = itemName.roleName
          //     }
          //   })
          // })
        } else {
          this.tableData = res.data.data
          this.total = ""
          this.$message.info(res.data.message)
        }
      }).catch(error => {
        // console.log(error.response.status);
        // if (error.response.status == 401) {
        //   this.$confirm('登录状态过期, 请重新登录!', '提示', {
        //     confirmButtonText: '确定',
        //     // cancelButtonText: '取消',
        //     showCancelButton: false,
        //     type: 'warning'
        //   }).then(() => {
        //     this.$router.push('/login')
        //   }).catch(() => {

        //   })
        // }
      })
    },
    //获取校区名称
    getCampusName() {
      getCampusName({userId:window.localStorage.getItem('id')}).then(res => {
        // console.log(res)
        if (res.status == 200) {
          this.CampusName = res.data.data
        }
      })
    },
    //获取学院名称
    getCollegeName() {
      getCollegeName().then(res => {
        // console.log(res)
        if (res.status == 200) {
          this.CollegeName = res.data.data
        }
      })
    },
    //获取部门名称
    getDepartmentName() {
      getDepartmentName({
        departType: 0
      }).then(res => {
        // console.log(res)
        if (res.status == 200) {
          this.DepartmentName = res.data.data
        }
      })
    },
    // 获取角色
    getRole() {
      getRoles().then(res => {
        // console.log(res)
        if (res.status == 200) {
          this.Role = res.data.data
        }
      })
    },

  },
  created() {
    this.getSchoolWorker()
    // this.getCampusName()
    // this.getCollegeName()
    // this.getDepartmentName()
  },
};
</script>
<style lang="scss" scoped>
.btnBox {
  display: flex;
  width: 80%;
  height: 34px;
  justify-content: space-between;
}

.btnBox_left {
  display: flex;
  margin-left: 50px;
}

.search_button {
  margin-left: 10px;
}

.reset_button {
  margin-left: 10px;
}

// .delete_button{
//   margin-left: 10px;
// }
// .dialogbutton{
//   margin-right: 40%;
// }
.pagination {
  float: right;
  margin-top: 10px;
}
</style>
